package com.agua.enturno.vista;

import com.agua.enturno.vista.paginas.adm.agendas.AgendasPage;
import com.agua.enturno.vista.paginas.home.HomePage;
import com.agua.enturno.vista.paginas.login.LoginPage;
import com.agua.enturno.vista.paginas.login.RegistrationPage;
import com.agua.enturno.vista.paginas.perfil.ProfilePage;
import com.agua.enturno.vista.paginas.prestador.PrestadorPage;
import com.agua.enturno.vista.paginas.turnos.TurnosPage;
import org.apache.wicket.Session;
import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession;
import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

public class WicketApplication extends AuthenticatedWebApplication {

	@Override
	public Class<? extends BasePage> getHomePage() {
		return HomePage.class;
	}

	@Override
	public void init() {
		
		super.init();
		this.getComponentInstantiationListeners().add(new SpringComponentInjector(this));
		
		// Montamos las paginas para que tengan nice url
		mountPage("/home", HomePage.class);
        mountPage("/login", LoginPage.class);
        mountPage("/register", RegistrationPage.class);
        mountPage("/prestadores/${prestadorId}", PrestadorPage.class);
        mountPage("/adm-agendas", AgendasPage.class);
        mountPage("/perfil", ProfilePage.class);
        mountPage("/turnos", TurnosPage.class);
	}

	@Override
	public Session newSession(Request request, Response response) {
		return new EnTurnoSession(request);
	}
	
	@Override
	protected Class<? extends WebPage> getSignInPageClass() {
		return LoginPage.class;
	}

	@Override
	protected Class<? extends AbstractAuthenticatedWebSession> getWebSessionClass() {
		return EnTurnoSession.class;
	}
	
}
